<template>
  <div>
    <!-- 居家 -->
    <section>
      <div class="at-home">
        <div class="container">
          <div class="good-title">
            <div class="title-left">
              <template v-if="goodsList.length == 0">
                <el-skeleton />
              </template>
              <h1 v-else>{{ goodsList[0].name }}</h1>
            </div>
            <div class="jujia">
              <a href="#">居家用品</a>
              <a href="#">居家用品</a>
              <a href="#">保健</a>
              <a href="#">居家用品</a>
              <a href="#">居家用品</a>
              <a href="#">居家用品</a>
              <a href="#">居家用品</a>
            </div>
            <div class="title-right"><a href="">查看全部 ></a></div>
          </div>
          <div class="home-list">
            <template v-if="goodsList.length == 0">
              <el-skeleton />
            </template>
            <div class="list-left" v-else>
              <img :src="goodsList[0].picture" alt="" />
              <div class="mask">
                <div class="mask-left">{{ goodsList[0].name }}馆</div>
                <div class="mask-right">{{ goodsList[0].saleInfo }}</div>
              </div>
            </div>
            <div class="list-right">
              <ul>
                <template v-if="goodsList.length == 0">
                  <el-skeleton />
                </template>
                <li v-else v-for="good in atHomeList" :key="good.id">
                  <div class="item">
                    <img :src="good.picture" alt="" />
                    <div class="item-title">
                      <h3>{{ good.name }}</h3>
                      <p>{{ good.desc }}</p>
                      <span>￥{{ good.price }}</span>
                    </div>
                  </div>
                  <!-- 隐藏 -->
                  <div class="item-yc">
                    <div class="yc-title">
                      <div class="yc-top">找相似</div>
                      <div class="yc-bottom">发现更多宝贝</div>
                    </div>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  mounted() {
    this.$store.dispatch("getGoodsList");
  },
  computed: {
    ...mapState({
      goodsList: (state) => state.home.goodsList,
    }),
    atHomeList() {
      return this.goodsList[0].goods;
    },
  },
};
</script>

<style>
.at-home {
  height: 725px;
  background-color: #ffffff;
}

.at-home .jujia {
  width: 890px;
  height: 35px;
  text-align: right;
  display: inline-block;
  transform: translate(150px, 5px);
}

.at-home .jujia a {
  font-size: 16px;
  margin-right: 25px;
}
.at-home .jujia a:hover {
  color: #27ba9b;
}
.home-list {
  height: 610px;
  float: left;
}

.home-list .list-left {
  position: relative;
  width: 240px;
  height: 610px;
  float: left;
}

.home-list .list-left img {
  width: 100%;
  height: 100%;
}

.home-list .list-left .mask {
  position: absolute;
  top: 50%;
  left: 0;
  width: 188px;
  height: 66px;
  line-height: 66px;
  font-size: 18px;
  color: #ffffff;
  text-align: center;
}

.home-list .mask .mask-left {
  width: 76px;
  height: 66px;
  background: rgba(0, 0, 0, 0.8);
  float: left;
}

.home-list .mask .mask-right {
  width: 112px;
  height: 66px;
  background: rgba(0, 0, 0, 0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  float: left;
}

.home-list .list-right {
  width: 990px;
  height: 610px;
  float: left;
}

.home-list .list-right ul {
  width: 100%;
  height: 100%;
}

.home-list .list-right ul li {
  position: relative;
  width: 240px;
  height: 300px;
  float: left;
  padding: 10px 25px;
  margin: 0 0 10px 6px;
  border: transparent;
}

.home-list .list-right ul li:hover {
  transition: all 1s linear;
  border: 1px solid #27ba9b;
  cursor: pointer;
}

.home-list .list-right .item-yc {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: absolute;
  left: 0;
  bottom: -1px;
  content: "";
  width: 100%;
  height: 0;
  background-color: #27ba9b;
}

.home-list .list-right ul li:hover .item-yc {
  height: 30%;
  transition: all 0.3s linear;
}

.item-yc .yc-title {
  color: #ffffff;
  text-align: center;
}

.item-yc .yc-title .yc-top {
  width: 100px;
  font-size: 20px;
  padding: 0 0 8px 0;
  margin: 0 0 5px 0;
  border-bottom: 1px solid #ffffff;
}
.item-yc .yc-title .yc-bottom {
  font-size: 16px;
}

.home-list .list-right ul li .item {
  width: 179px;
  text-align: center;
}

.home-list .list-right .item img {
  width: 160px;
  height: 160px;
  padding-bottom: 5px;
}

.home-list .list-right .item-title {
  width: 178px;
}

.home-list .list-right .item-title {
  text-align: left;
}

.home-list .item-title p {
  display: inline-block;
  width: 178px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 0;
}

.home-list .item-title span {
  color: red;
  font-size: 20px;
}
</style>